# Build recipe for markupsafe.
#
# Copyright (C) 2019-2022 Matias Fonzo, <selk@dragora.org>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Exit immediately on any error
set -e

program=MarkupSafe
version=2.0.1
release=1

pkgname=python-${program}

# Define a category for the output of the package name
pkgcategory=python

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch=https://files.pythonhosted.org/packages/bf/10/ff66fea6d1788c458663a84d88787bae15d45daa16f6b3ef33322a51fc7e/$tarname

description="
A Python module that implements a XML/HTML/XHTML Markup safe string.

MarkupSafe implements a text object that escapes characters so it is
safe to use in HTML and XML.  Characters that have special meanings
are replaced so that they display as the actual characters.  This
mitigates injection attacks, meaning untrusted user input can safely
be displayed on a page.  Escaping is implemented in C so it is as
efficient as possible.
"

homepage=https://palletsprojects.com/p/markupsafe
license="BSD License (BSD-3-Clause)"

docs="CHANGES* LICENSE* PKG-INFO README*"
docsdir="${docdir}/${pkgname}-${version}"

build()
{
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    # Set sane permissions
    chmod -R u+w,go-w,a+rX-s .

    python3 setup.py build
    python3 setup.py install --prefix=/usr --root="$destdir" --optimize=1

    # Copy documentation
    mkdir -p "${destdir}/$docsdir"
    cp -p $docs "${destdir}/$docsdir"
}

